import {defineStore} from 'pinia'

export const useCountStore = defineStore('count',{
    actions:{
        //加
        increment(value:number) {
            if (this.sum < 10) {
                //操作countStore中的sum
                this.sum += value
            }
        },
        //减
        decrement(value:number){
            if(this.sum > 1){
                this.sum -= value
            }
        }
    },
    // 真正存储数据的地方
    state(){
        return {
            sum:6,
            school: 'shangguigu',
            address: '重庆'
        }
    },

    // 计算
    getters:{
        bigSum:(state):number => state.sum *10,
        upperSchool():string{
            return this. school.toUpperCase()
        }
    }
})